<!DOCTYPE html>
<html>
<head lang="zh">
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>病人详情</title>
    <link rel="stylesheet" href="./layer/theme/default/layer.css">
    <link rel="stylesheet" type="text/css" href="./css/reponse.css">
    <link href="../css/style.css" rel="stylesheet" type="text/css"/>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
        <script type="text/javascript" src="../js/slider.js"></script>
    <style type="text/css">
        .alertceng {
            background: #FFFFFF;
            padding: 10px;
            display: none;
        }

        .alertceng span.title {
            margin-right: 10px;
        }
        .but{
            float:left; background-color: blue;border: none;outline: none;white-space: nowrap;
    text-align: center;
    background-image: none;
    border: 1px solid transparent;
    -webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.015);
    box-shadow: 0 2px 0 rgba(0,0,0,0.015);
    cursor: pointer;
    -webkit-transition: all .3s cubic-bezier(.645, .045, .355, 1);
    transition: all .3s cubic-bezier(.645, .045, .355, 1);
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -ms-touch-action: manipulation;
    touch-action: manipulation;
    padding: 0 15px;
    
    font-size: 14px;
    border-radius: 4px;
    color: rgba(0,0,0,0.65);
    background-color: #fff;
    border-color: #d9d9d9;"
        }
        .btu{
    background: none;
    color: #009cfd;
    border-radius: 3px;
    border: 1px solid #009cfd;
    font-size: 1rem;
    padding: 0.13rem 0.5rem;
}
    </style>
</head>
<body>
<div class="layui-fluid layadmin-homepage-fluid" style="background: #fff;width:90%;margin:10px auto;">
    <a onclick="edit12()"><input type="text" style="float:left;display:inline-block" disabled id="myInput2"  placeholder=""></a>
    <!-- onkeyup="myFunction()" -->
    <button class="btu" style="float:right;display:inline-block" onclick="myFunction()">开方</button></br></br></br>
    <div id="page">
        <!-- <table id="table" class="reponsetable" name="Table"></table> -->
    </div>
</div>
</body>
<script src="https://www.jq22.com/jquery/jquery-1.7.1.js"></script>
<script src="../comment.js"></script>
<script type="text/javascript" src="./js/jquery.basictable.min.js"></script>
<script type="text/javascript" src="./reponsetable.min.js"></script>
<script type="text/javascript" src="layer/layer.js"></script>
<script type="text/javascript">
    function getParams(key) {
        var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return unescape(r[2]);
        }
        return null;
    };
    $(function () {
        $("#myInput2").val(sessionStorage.getItem("p_name"));
        //sessionStorage.removeItem("p_name");
        getdata();
    });
    var Const = '';
    function   ages(str)
    {
        var   r   =   str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
        if(r==null)return   false;
        var   d=   new   Date(r[1],   r[3]-1,   r[4]);
        if   (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4])
        {
            var   Y   =   new   Date().getFullYear();
            return((Y-r[1])+"岁");
        }
        return("0");
    }
    function edit12() {
        if(getParams("id")==null||getParams("id")===""){
            alert("病人信息有误")
        }else {
            var Eurl = "../info/p_info.html?id="+getParams("id");
            var Eurl2 = encodeURI(Eurl);
            window.location.href=Eurl2;
        }
    }
    function  getdata() {
        if(getParams("id")==null||getParams("id")===""){
            alert("病人信息有误")
        }else {
            $.ajax({
                type: "GET",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: MyServer+"h5/patient_kf_getByid/"+getParams("id") ,//url 47.103.1.210:8082/guns-1.0.0
                headers: {
                    "Authorization" : sessionStorage.getItem("Authorization"),
                },
                success: function (result) {
                    console.log(result)
                    if(result.code===200){
                        var datas=[];
                        var html = '';
                        if(result.data.length===0){
                            html+='<div class="jq22-list-head"><h2>药方列表：暂无药方</h2></div>';
                        }else {
                            html+='<div class="jq22-list-head"><h2>药方列表</h2></div>';
                            for(var i=0;i<result.data.length;i++){
                                // var t = {"name": result.data[i].name, "sex": result.data[i].sex, "age": result.data[i].age, "disease": result.data[i].diagnosis,
                                //     "kfid": "<button class='btn' name="+result.data[i].kfid+" onclick=tail(this)>详情</button>"};
                                // datas.push(t);
                                var diagnosis='';
                                if(result.data[i].diagnosis.length>12){
                                    diagnosis = result.data[i].diagnosis.substring(0,12)+"...";
                                }else {
                                    diagnosis = result.data[i].diagnosis
                                }
                                html+='<div class="jq22-list-cell" id="'+result.data[i].kfid+'">';
                                html+='   <a href="javascript:;" class="jq22-list-cell-item" style="width:100%">';
                                html+='       <div class="jq22-list-cell-item-info jq22-list-cell-item-info-thr" style="margin-right:0;width:100%">';
                                html+='            <h2 style="float:left;display:inline-block;">'+diagnosis+'</br>开方时间：'+result.data[i].kf_time+'</h2>';
                                var types='';
                                var txt = "";
                                if(result.data[i].type==="1"){
                                    if(result.data[i].tag==="0"){
                                        types = "未取药";
                                    }else {
                                        types = "已取药";
                                    }
                                    txt = "详情";
                                }else {
                                    types =  "药方草稿";
                                    txt = "完善药方"
                                }
                                html+='            <h2 style="float:right;display:inline-block;">'+types+'</br>' +
                                    '<button class="btn" style="margin-top:1.5em;float:right;display:inline-block" ' +
                                    'name="'+result.data[i].kfid+'" onclick=tail(this)>'+txt+'</button></h2>';
                                html+='        </div>';
                                html+='    </a>';
                                html+='</div>';
                            }
                        }

                        Const = html;
                        $("#page").html(html)


                    }else if(result.code===401){
                        alert("您未登陆")
                    }else if(result.code===405){
                        alert(result.message);
                    }else {
                        alert("服务器开小差了！")
                    }
                },
                error:function(data){
                    if(data.status===401){
                        alert("您未登陆")
                    }else if(data.code===405){
                        alert(data.message);
                    }else{
                        alert("服务器开小差了！")
                    }
                }
            });
        }

        return 1;
    }
    function tail(obj){
        //console.log($(obj).parent().parent().find("td")) //一个人的数据[0-5]
        var kfid = $(obj).attr("name");
        var Eurl = "../dislyb/dislyb2.html?kfid="+kfid;
        var Eurl2 = encodeURI(Eurl);
        window.location.href=Eurl2;
    }
function getAgent(input) {
            filter = input.value.toUpperCase();
            table = document.getElementById("page");
            tr = table.children.length
            var htmls = '<div class="jq22-list-head"><h2>药方列表</h2></div>';
            for (var i = 1; i < tr; i++) {
                //console.log(table.children[i].firstElementChild.firstElementChild.firstElementChild.innerText)
                var texts = table.children[i].firstElementChild.firstElementChild.firstElementChild.innerText;
                if (texts.toUpperCase().indexOf(filter) > -1) {
                    htmls += table.children[i].innerHTML;
                    console.log(1)
                }else{
                    console.log(2)
                }
            }
            $("#page").html(htmls)
}

    function myFunction() {
        if(getParams("id")===""||getParams("id")==null){
            alert("病人数据错误")
        }else {
            // 声明变量
            var Eurl = "../kf/kf.html?id="+getParams("id");
            var Eurl2 = encodeURI(Eurl);
            window.location.href=Eurl2;
        }
    }

    </script>
</html>